<?php if($is_cancelable) { ?><a class="btn btn-primary" href="<?php echo base_url('service/add_order/'.$resv_id); ?>"><i class="icon-plus icon-white"></i>Add Order</a>
<br><br><?php } ?>
<?php
	
	foreach($order as $row) {
		echo '<table class="table table-bordered table-hover table-condensed">';
		echo '<tr>
				<th>Invoice Code</th>
				<td>'.$row['serv_ord_id'].'</td>
			</tr>';
		echo '<tr>
				<th>Time</th>
				<td>'.$row['serv_ord_time'].'</td>
			</tr>';
		echo '<tr>
				<th>Location</th>
				<td>'.$row['room_name'].'</td>
			</tr>';
		echo '<tr>
				<th>Staff</th>
				<td>'.$row['emp_name'].'</td>
			</tr>';
		echo '<tr>
				<th>Guest</th>
				<td>'.$row['guest_name'].'</td>
			</tr>';
		echo '<tr>
				<th>Description</th>
				<td>'.$row['serv_ord_desc'].'</td>
			</tr>';
		echo '<tr>
				<th>Services</th>
				<td>
					<table class="table table-bordered table-hover table-condensed">
						<tr>
							<th>Code</th>
							<th>Name</th>
							<th>Price</th>
							<th>Qty</th>
							<th>UoM</th>
							<th>Total</th>
						</tr>';
		$gtotal=0;
		foreach($row['serv_det'] as $row2) {
			$total = $row2['serv_det_price'] * $row2['serv_det_qty'];
			$gtotal += $total;
			echo '<tr>';
			echo '<td>'.$row2['service_code'].'</td>';
			echo '<td>'.$row2['service_name'].'</td>';
			echo '<td>Rp. '.number_format($row2['serv_det_price'],2,',','.').'</td>';
			echo '<td>'.number_format($row2['serv_det_qty'],3,',','.').'</td>';
			echo '<td>'.$row2['service_uom'].'</td>';
			echo '<td>Rp. '.number_format($total, 2, ',','.').'</td>';
			echo '</tr>';
		}
		echo '<tr><td colspan="6"></td></tr>';
		echo '<tr>';
		echo '<td colspan="4">Discount</td>';
		$discount = 0;
		if($row['discount_percent'] != null) {
			echo '<td>'.number_format($row['discount_percent'],2,',','.').'%</td>';
			$discount = $gtotal * $row['discount_percent'] / 100;
			$gtotal = $gtotal - $discount;
		}
		else if($row['discount_nominal'] != null){
			echo '<td>Rp. '.number_format($row['discount_nominal'],2,',','.').'</td>';
			$discount = $row['discount_nominal'];
			$gtotal = $gtotal - $discount;
		}
		else{
			echo '<td>%</td>';
		}
		echo '<td>Rp. '.number_format($discount,2,',','.').'</td>';
		echo '</tr>';
		
		echo '<tr><td colspan="5">Sub Total</td><td>Rp. '.number_format($gtotal,2,',','.').'</td></tr>';
		
		echo '<tr>';
		echo '<td colspan="4">PPn Tax</td>';
		echo '<td>'.$row['ppn_tax'].'%</td>';
		$ppn = $gtotal * $row['ppn_tax'] /100;
		echo '<td>Rp. '.number_format($ppn,2,',','.').'</td>';
		echo '</tr>';
		
		echo '<tr>';
		echo '<td colspan="4">Service Tax</td>';
		echo '<td>'.$row['service_tax'].'%</td>';
		$service = $gtotal * $row['service_tax'] /100;
		echo '<td>Rp. '.number_format($service,2,',','.').'</td>';
		echo '</tr>';
		
		$gtotal = $gtotal + $ppn + $service;
		
		echo '<tr><td colspan="5">Grand Total</td><th>Rp. '.number_format($gtotal,2,',','.').'</th></tr>';
		
		
		echo 		'</table>
				</td>
			</tr>
		</table>';
	}
	
?>
<a href="<?= base_url('reservation') ?>" class="btn">Back to Reservation</a>
<br><br>
		